package com.olive.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;

@RestController
public class TestController {

	@RequestMapping("/repeatRead")
	public Map<String, Object> repeatRead(HttpServletRequest request){
		Map<String, Object> result = new HashMap<>();
		result.put("code", 200);
		result.put("msg", "success");
		try {
			ServletInputStream in = request.getInputStream();
			byte[] buffer = new byte[1024];
			int len = in.read(buffer);
			System.out.println(new String(buffer, 0 ,len));
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println("------------------------");
		try {
			ServletInputStream in = request.getInputStream();
			byte[] buffer = new byte[1024];
			int len = in.read(buffer);
			System.out.println(new String(buffer, 0 ,len));
		} catch (IOException e) {
			e.printStackTrace();
		}
		return result;
	}

}
